import request from './request';

export function login(data: any) {
  return request({
    url: '/api/user/login',
    method: 'post',
    data,
  });
}

export function register(data: any) {
  return request({
    url: '/api/user/register',
    method: 'post',
    data,
  });
}

export function getUserInfo() {
  return request({
    url: '/api/user/info',
    method: 'get',
  });
}

// 发送忘记密码验证码
export function sendForgotPasswordCode(data: any) {
  return request({
    url: '/api/user/forgot-password/send-code',
    method: 'post',
    data,
  });
}

// 通过验证码重置密码
export function resetPasswordByCode(data: any) {
  return request({
    url: '/api/user/forgot-password/reset',
    method: 'post',
    data,
  });
}

export function checkUsername(username: string) {
  return request({
    url: `/api/user/check-username?username=${username}`,
    method: 'get',
  });
}